#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
    int fd = open(argv[1], O_RDONLY);
    int fd2 = open(argv[2], O_CREAT | O_WRONLY);

    int length = 512;
    char buf[length];
    int status;

    while (1)
    {
        status = read(fd, buf, sizeof(buf)-1);

        if (status == 0)
            break;

        write(fd2, buf, status);
    }

    close(fd);
}   